﻿{% if actual_quote_request.items_count > 0 %}
    {% unless customer == nil %}
        <script>
            var defaultCustomerAddress = {% if actual_quote_request.shipping_address == nil %}{{ customer.default_address | json }}{% else %}null{% endif %};
        </script>
    {% endunless %}
    <form action="{{ shop.simplified_url }}/quotes" method="post" novalidate>
        <input id="actual-quote-request-id" type="hidden" value="{{ actual_quote_request.id }}" />
        <h1 class="h2">{{ 'quotes.general.title' | t }}</h1>
        {% unless customer == nil %}
            <div class="grid">
                <div class="grid-item">
                    <div class="ublock">
                        <h4>E-mail address</h4>
                        <input id="actual-quote-request-email" type="text" value="{{ customer.email }}" />
                    </div>
                </div>
            </div>
        {% endunless %}
        <div class="grid">
            <div class="grid-item">
                <div class="ublock">
                    <h4>{{ 'quotes.general.remarks.title' | t }}</h4>
                    <p>{{ 'quotes.general.remarks.text' | t }}</p>
                    <textarea id="actual-quote-request-comment">{{ actual_quote_request.comment }}</textarea>
                    <input {% if actual_quote_request.shipping_required %}checked="checked"{% endif %} id="actual-quote-request-shipping-quote" type="checkbox" /> {{ 'quotes.general.request_shipping_quote' | t }}
                </div>
            </div>
        </div>
        {% for item in actual_quote_request.items %}
            <div class="cart-row quote" data-id="{{ item.id }}" data-default-tier-price="{{ item.list_price }}">
                <div class="grid">
                    <div class="grid-item large--seven-twelfths">
                        <div class="grid">
                            <div class="grid-item one-third large--one-quarter">
                                <a class="cart-image" href="">
                                    <img alt="{{ item.title }}" src="{{ item.image_url }}" title="{{ item.title }}" />
                                </a>
                            </div>
                            <div class="grid-item one-third">
                                <a href="">{{ item.title }}</a>
                            </div>
                            <div class="grid-item one-third">
                                <textarea class="quote_item_comment">{{ item.comment }}</textarea>
                            </div>
                        </div>
                    </div>
                    <div class="grid-item large--five-twelfths medium--two-thirds push--medium--one-third">
                        <div class="grid">
                            <div class="grid-item one-half medium-down--one-third text-right">
                                {% for tier_price in item.proposal_prices %}
                                    <div class="js-qty" data-for-proposal-price="{{ forloop.index }}">
                                        <div class="js-qty--inner">
                                            <input class="js--num" pattern="[0-9]*" type="text" value="{{ tier_price.quantity }}" />
                                            <input class="js--price" type="hidden" value="{{ tier_price.price }}" />
                                            <span class="js--qty-adjuster js--add" data-id="{{ item.id }}">+</span>
                                            <span class="js--qty-adjuster js--minus" data-id="{{ item.id }}">-</span>
                                        </div>
                                        {% if forloop.index > 1 %}
                                            <a class="link-action">{{ 'quotes.general.remove' | t }}</a>
                                        {% endif %}
                                    </div>
                                {% endfor %}
                                <div class="js-qty">
                                    <a class="add-tier" style="cursor: pointer;">Add tier</a>
                                </div>
                            </div>
                            <div class="grid-item one-third medium-down--one-third medium-down--text-left text-right proposal-prices">
                                {% for proposal_price in item.proposal_prices %}
                                    <span class="h2" data-proposal-price="{{ forloop.index }}">
                                        <small>{{ proposal_price.price | money }}</small>
                                    </span>
                                {% endfor %}
                            </div>
                            <div class="grid-item one-sixth medium-down--one-third text-right">
                                <a class="icon-fallback-text btn-secondary remove" data-id="{{ item.id }}" href="{{shop.simplified_url}}/quote/remove?id={{item.id}}">
                                    <span aria-hidden="true" class="icon icon-x"></span>
                                    <span class="fallback-text">{{ 'quotes.general.remove' | t }}</span>
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        {% endfor %}
        <div class="grid">
            <div class="grid-item">
                <div class="ublock" id="shipping-address-block" style="display: none;">
                    <div class="h3">Shipping address</div>
                    <div class="grid">
                        <div class="grid-item large--one-half">
                            <label>First name</label>
                            <input id="actual-quote-request-shipping-address-first-name" type="text" value="{{ actual_quote_request.shipping_address.first_name }}" />
                            <label>Last name</label>
                            <input id="actual-quote-request-shipping-address-last-name" type="text" value="{{ actual_quote_request.shipping_address.last_name }}" />
                            <label>Country</label>
                            <select id="actual-quote-request-shipping-address-country">{{ country_option_tags }}</select>
                            <label>Province</label>
                            <select data-default="{{ actual_quote_request.shipping_address.province }}" id="actual-quote-request-shipping-address-province"></select>
                            <label>City</label>
                            <input id="actual-quote-request-shipping-address-city" type="text" value="{{ actual_quote_request.shipping_address.city }}" />
                        </div>
                        <div class="grid-item large--one-half">
                            <label>Company</label>
                            <input id="actual-quote-request-shipping-address-company" type="text" value="{{ actual_quote_request.shipping_address.company }}" />
                            <label>Address line 1</label>
                            <input id="actual-quote-request-shipping-address-address1" type="text" value="{{ actual_quote_request.shipping_address.address1 }}" />
                            <label>Address line 2</label>
                            <input id="actual-quote-request-shipping-address-address2" type="text" value="{{ actual_quote_request.shipping_address.address2 }}" />
                            <label>Zip/Postal code</label>
                            <input id="actual-quote-request-shipping-address-zip" type="text" value="{{ actual_quote_request.shipping_address.zip }}" />
                            <label>Phone</label>
                            <input id="actual-quote-request-shipping-address-phone" type="text" value="{{ actual_quote_request.shipping_address.phone }}" />
                        </div>
                    </div>
                    <input {% if actual_quote_request.billing_address_equals_shipping_address %}checked="checked"{% endif %} id="actual-quote-request-same-billing-address" type="checkbox" /> Billing Address is same as Shipping Address 
                </div>
                <div class="ublock" id="billing-address-block" style="display: none;">
                    <div class="h3">Billing address</div>
                    <div class="grid">
                        <div class="grid-item large--one-half">
                            <label>First name</label>
                            <input id="actual-quote-request-billing-address-first-name" type="text" value="{{ actual_quote_request.billing_address.first_name }}" />
                            <label>Last name</label>
                            <input id="actual-quote-request-billing-address-last-name" type="text" value="{{ actual_quote_request.billing_address.last_name }}" />
                            <label>Country</label>
                            <select id="actual-quote-request-billing-address-country">{{ country_option_tags }}</select>
                            <label>Province</label>
                            <select data-default="{{ actual_quote_request.billing_address.province }}" id="actual-quote-request-billing-address-province"></select>
                            <label>City</label>
                            <input id="actual-quote-request-billing-address-city" type="text" value="{{ actual_quote_request.billing_address.city }}" />
                        </div>
                        <div class="grid-item large--one-half">
                            <label>Company</label>
                            <input id="actual-quote-request-billing-address-company" type="text" value="{{ actual_quote_request.billing_address.company }}" />
                            <label>Address line 1</label>
                            <input id="actual-quote-request-billing-address-address1" type="text" value="{{ actual_quote_request.billing_address.address1 }}" />
                            <label>Address line 2</label>
                            <input id="actual-quote-request-billing-address-address2" type="text" value="{{ actual_quote_request.billing_address.address2 }}" />
                            <label>Zip/Postal code</label>
                            <input id="actual-quote-request-billing-address-zip" type="text" value="{{ actual_quote_request.billing_address.zip }}" />
                            <label>Phone</label>
                            <input id="actual-quote-request-billing-address-phone" type="text" value="{{ actual_quote_request.billing_address.phone }}" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="ublock text-right">
            <button class="btn" id="btn-submit-quote-request" type="button">{{ 'quotes.general.submit_quote' | t }}</button>
        </div>
    </form>
{% else %}
    <h2>{{ 'quotes.general.empty' | t }}</h2>
    <p>{{ 'quotes.general.continue_browsing_html' | t }}</p>
{% endif %}